package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.pojos.WmChannel;
import com.heima.wemedia.service.WmChannelService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/api/v1/channel")
public class WmChannelController {

    @Resource
    private WmChannelService wmChannelService;

    /**
     * 查询所有频道
     * @return
     */
    @GetMapping("channels")
    public ResponseResult findAll() {

        return wmChannelService.findAll();
    }
    /**
     * 保存或更新频道
     * @param wmChannel
     * @return
     */
    @PostMapping("save")
    public ResponseResult save(@RequestBody WmChannel wmChannel) {
        return ResponseResult.okResult(wmChannelService.saveOrUpdate(wmChannel)) ;
    }

}
